import QtQuick 2.4
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2

Rectangle {
    id: rectangle2
    width: 720
    height: 1280
    color: "#f6f6f6"

    Rectangle {
        id: rectangle3
        height: 120*rectangle2.height/1280
        color: "#f0f0f0"
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: parent.top
        anchors.topMargin: 0

        Text {
            id: text8
            text: qsTr("FileDialog Test")
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
            font.pixelSize: 45*rectangle2.height/1280
        }

        Text {
            id: image2
            width: height
            text:"+"
            font.pixelSize: width
            anchors.right: parent.right
            anchors.rightMargin: 10*rectangle2.width/720
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 20*rectangle2.height/1280
            anchors.top: parent.top
            anchors.topMargin: 20*rectangle2.height/1280

            MouseArea {
                id: mouseArea2
                anchors.topMargin: -20*rectangle2.height/1280
                anchors.bottomMargin: -20*rectangle2.height/1280
                anchors.leftMargin: -10*rectangle2.width/720
                anchors.rightMargin: -10*rectangle2.width/720
                anchors.fill: parent
                onClicked: {
                    choose_dir.open()
                }
            }
        }
    }

    FileDialog {
        id: choose_dir
        selectMultiple: false
        selectExisting: true
        selectFolder: true
        sidebarVisible: false
        onAccepted: {
            file.text = qsTr("Choose:")+choose_dir.folder
            more_info.visible = true
            console.log("choose_dir_y")
        }
    }

    Rectangle {
        id: more_info
        visible:false
        x: 90*rectangle2.width/720
        y: 180*rectangle2.height/1280
        width: 540*rectangle2.width/720
        height: 960*rectangle2.height/1280
        color: "#f6f6f6"
        radius: 10*Math.sqrt(rectangle2.height/1280*rectangle2.width/720)
        border.color: "#c1c1be"
        border.width: 5*Math.sqrt(rectangle2.height/1280*rectangle2.width/720)
        Button {
            id: button1
            width: 270*rectangle2.width/720
            height: 70*rectangle2.height/1280
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 0

            Text {
                id: text1
                text: qsTr("确定")
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
                font.pixelSize: 55*Math.sqrt(rectangle2.height/1280*rectangle2.width/720)
            }

            onClicked: {
                more_info.visible = false
            }
        }


        Text {
            id: file
            text: qsTr("Choose:")
            anchors.left: parent.left
            anchors.leftMargin: 5*rectangle2.width/720
            anchors.top: parent.top
            anchors.topMargin: 20*rectangle2.width/720
            font.pixelSize: 35*Math.sqrt(rectangle2.height/1280*rectangle2.width/720)
        }
    }
}
